package com.example.Laboratory.Controller;

import com.example.Laboratory.Service.OrganizationService;
import com.example.Laboratory.Untils.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;

@Api(value = "Organization", description = "组织机构")
@RestController
@RequestMapping(value = "/Organization")
@CrossOrigin
public class OrganizationController {

    @Autowired
    OrganizationService organizationService;

    @ApiOperation(value = "增加组织机构图片", notes = "增加组织机构图片")
    @RequestMapping(value = "/addOrganization", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object addOrganization(MultipartFile file) throws IOException {
        return ResultCode.SUCCESS.result(organizationService.addOrganization(file));
    }

    @ApiOperation(value = "删除组织机构图片", notes = "删除组织机构图片")
    @RequestMapping(value = "/deleteOrganization", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
    public Object deleteOrganization(int organization_id) throws IOException {
        return ResultCode.SUCCESS.result(organizationService.deleteOrganization(organization_id));
    }

    @ApiOperation(value = "查找组织机构图片", notes = "查找组织机构图片")
    @RequestMapping(value = "/researchOrganization", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object researchOrganization() throws IOException {
        return ResultCode.SUCCESS.result(organizationService.researchOrganization());
    }

    @ApiOperation(value = "修改组织机构图片", notes = "修改组织机构图片")
    @RequestMapping(value = "/reviseOrganization", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object reviseOrganization(MultipartFile file, int organization_id) throws IOException {
        return ResultCode.SUCCESS.result(organizationService.reviseOrganization(file, organization_id));
    }
}
